package com.rp.data.tcp_ws.server_tcp.echo;

import sun.misc.CRC16;

public class Test {

    public static void main(String[] args) {
        dd(new byte[]{0x08, (byte) 0xae, (byte) 0xf7,0x51},new byte[]{0x04, (byte) 0xd2, (byte) 0xfb,0x2d});
        CRC16 crc16 = new CRC16();
        crc16.update((byte) 0x08);
        crc16.update((byte) 0xae);
        System.out.println(crc16.value);
    }

    public static void dd(byte[] bytes,byte[] bytes2) {
        int a1 = (bytes[0] & 0xFF) << 8 | bytes[1] & 0xFF;
        int b1 = (bytes[2] & 0xFF) << 8 | bytes[3] & 0xFF;
        System.out.println(a1+" "+b1);

        int a2 = (bytes2[0] & 0xFF) << 8 | bytes2[1] & 0xFF;
        int b2 = (bytes2[2] & 0xFF) << 8 | bytes2[3] & 0xFF;
        System.out.println(a2+" "+b2);

        System.out.println((a1-a2) +"  " +(b1-b2));
    }
}
